<template>
  <div class="form">
    <FormItem class="formItem" :roleRules="ruleCustom" :formData="formData" :formItem="formItem" @addFile="addFile">
    </FormItem>
  </div>
</template>

<script>
import FormItem from '@/commont/plugins/formItem.vue'
export default {
  name: "formData",
  components: { FormItem },
  props: {},
  data() {
    let stateOptionCha = [
      { label: '基础套餐', value: 1 },
      { label: '二级栏目', value: 2 },
      { label: '业务参数', value: 3 },
    ]
    return {
      ruleCustom: {// 校验规则
        paramKey: [{ required: true, message: '配置ID不能空', trigger: 'blur' }],
        paramValue: [{ required: true, message: '配置名称不可以为空', trigger: 'blur' }],
        siteCode: [{ required: true, message: '默认参数不可以为空', trigger: 'blur' }],
        paramType: [{ required: true, message: '配置类型不可以为空', trigger: 'blur' }],
      },
      formData: {
        paramKey: '',
        paramValue: '',
        siteCode: '',
        paramType: '',
        bgUrl: []
      },
      formItem: [
        { typeC: 'Input', type: 'text', label: '参数KEY', prop: 'paramKey', placeholder: '', disabled: false },
        { typeC: 'Switch', type: 'text', label: '参数名称', prop: 'paramValue', placeholder: '', disabled: false },
        { typeC: 'Input', type: 'text', label: '默认编码', prop: 'siteCode', placeholder: '', disabled: false },
        { typeC: 'Input', type: 'text', label: '参数类型', prop: 'paramType', placeholder: '', disabled: false, options: stateOptionCha },
        {
          typeC: 'Upload', label: '上传图片', prop: 'bgUrl', placeholder: '', disabled: false,
          params: {
            type: 'btn',
            btnType: 'primary',
            fileType: ['jpg', 'png', 'jpeg'],
            btnName: '上传图片',
            url: 'https://jsonplaceholder.typicode.com/posts/',
            limit: 1,
          }
        },
        {
          typeC: 'Upload', label: '上传图片', prop: 'bgUrl', placeholder: '', disabled: false,
          params: {
            type: 'list',
            url: '/iptv/epg/sichuan/categoryaudit/addPictures',
            data: { adType: '301' },
            // fileType:['jpg','png','jpeg'],
            limit: 1,
          }
        },
        {
          typeC: 'Upload', label: '上传文件', prop: 'bgUrl', placeholder: '', disabled: false,
          params: {
            type: 'btn',
            btnType: 'primary',
            data: { adType: '301' },
            fileType: ['jpg', 'png', 'jpeg'],
            width: 100,
            btnName: '上传文件',
            url: '/iptv/epg/sichuan/categoryaudit/addPictures',
            limit: 2,
          }
        },
      ],
    }
  },
  computed: {},
  watch: {},
  created() { },
  mounted() { },
  methods: {
    addFile(children) {
      children.$refs.input.click();
    }
  },
  filters: {},
}
</script>

<style lang="less" scoped>
.form {
  width: 100%;
  height: 100%;
  background-color: #fff;
  overflow-y: auto;

  .formItem {
    width: 50%;
  }
}
</style>